﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    class DBhper
    {
        public static string sqlcon = "Server=rm-bp13x228e5ip7ogsyzo.sqlserver.rds.aliyuncs.com,3433;uid=student;pwd=abc123!@#;database =Team4_DDBookDB";
        //查询方法
        public static SqlDataReader Selectdata(string sql)
        {
            SqlConnection conn = new SqlConnection(sqlcon);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataReader sr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            return sr;
        }
        //添加方法
        public static int AddData(string sql)
        {
            SqlConnection conn = new SqlConnection(sqlcon);
            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);
            int num = cmd.ExecuteNonQuery();
            conn.Close();
            return num;


        }
    }

}
